Skip to content

perf(screening): keep the counts Papers narrows by, and read a reviewer's papers by their cards - #1616

Merged
sickerine merged 2 commits into
devfrom
perf/screening-counts-kept
Nov 28, 2026
Merged

sickerine merged 2 commits into
devfrom
perf/screening-counts-kept

Conversation

@sickerine

Copy link
Copy Markdown
Collaborator

This is step one of two (widen, migrate, narrow) toward a fast Papers page when it's narrowed by a reviewer, source, check or reason.

Measured on a 5,000-paper screening with two reviewers (convex/bench/screening-team.bench.ts). Each call reads every card and every vote of the reviewer, and the page runs it again on every vote anyone casts:

Count Docs read now Docs read when step two ships
Tab counts, one reviewer 10,009 (2.8 MB) 252 (273 KB)
Tab counts, one reviewer voted Include 6,676 (1.7 MB) 92 (93 KB)
Tab counts, one source 5,009 (1.2 MB) 162 (170 KB)
Overview's votes of the last days 1,012 (314 KB) 58 (58 KB)

The "when step two ships" figures come from the same benchmark with both steps applied. Each count matched what the cards and votes say.

In this PR (nothing reads the new counts yet):

  • screeningFacetCounts, an aggregate kept by triggers on screeningResults and screeningVotes (convex/screening/facets.ts). It counts:
    • each paper under its source, its check and its reason
    • each vote under its reviewer, keyed by how they stand on it and where the paper stands
    • each cast vote, by when
  • migrations/screeningFacets backfills every paper and vote from before. verify returns how many entries are missing.
  • One reviewer's papers on Papers are filtered by each paper's card, a row of a few facts, instead of the whole paper with its abstract. A page of the Included tab reads 235 KB instead of 555 KB.
  • A vote's trigger reads its paper once per mutation, from what the papers' trigger saw. One reading step deals 2,000 votes on 200 papers it has just made. Read 2,000 times, that went past a transaction's 4,096 index ranges: the size tests found it.
  • The screening size tests now move fake time one second per turn. When they jumped every timer at once, the watch on a reading fired over and over while the counts were written in batches, and took the reading for one gone quiet.

After merging: push, run npx convex run migrations/screeningFacets:run, wait for migrations/screeningFacets:verify to return 0, then step two switches the reads.

Write cost: one aggregate entry per paper per narrowing, and one or two per vote. They are queued once per mutation and applied in batches of 1,024. Ten people on 5,000 papers is about 50 batches in the background.

Checks:

  • tsc, check:convex-rules, check:module-weight and check:user-actions pass.
  • Vitest on screening, migrations, sharing and the library: 428 pass.
  • The size tests (convex/limits/maxSizeScreening.test.ts, ten reviewers on 5,000 papers) pass under Convex's limits. They take 687 s here against 366 s on dev. The last successful nightly runs took about 8 minutes of their 30. The 27 November nightly was cancelled at 30 minutes before this change.

…er's papers by their cards

Step one of two (widen, migrate, narrow). Nothing reads the new counts yet: once the backfill has run and checked
clean on shared dev, the tab counts and the overview's votes of the last days read them (the next PR).

- screeningFacetCounts, an aggregate kept by triggers on papers and votes (convex/screening/facets.ts): each
  paper under its source, its check and its reason, each vote under its reviewer with where its paper stands,
  and each cast vote by when. A tab's count under one narrowing becomes a few counted reads.
- migrations/screeningFacets counts every paper and vote from before, with `verify` to check none is missing.
- One reviewer's papers on Papers are filtered by each paper's card, a few facts, rather than the paper with its
  abstract: 555 KB read for a page of Included at 5,000 papers before, 235 KB after.
- A vote's trigger reads its paper once a mutation: a step of a reading deals 2,000 votes on 200 papers it just
  made, and read 2,000 times they passed a transaction's 4,096 index ranges (the size tests caught it).
- convex/bench/screening-team.bench.ts measures what the pages read on a screening with two reviewers, and checks
  each count against the cards and votes.
- The size tests move time a second a turn: jumped to every timer at once, the watch on a reading woke over and
  over while the counts were written in batches, and took the reading for one gone quiet.
@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 01cb298c-a333-4fc3-8b37-cf724624c759
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-28T07:51:52.906782Z d18d7b8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d18d7b8771

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread convex/screening/facets.ts Resolved
…settling takes as many papers as its votes fit

From Codex's review of this PR and the cross-family review:
- A paper moved from one reviewer to another (move, and a reviewer joining) changes only the vote's reviewer;
  its counts stayed with the first. The vote trigger now moves them. facets.test.ts checks each reviewer's counts
  against their votes and the cards, read whole, as papers are moved, voted on and settled.
- The vote trigger reads every row written back twice, and settling may write a row twice. Thirty people on every
  paper, then "settled by the first vote", closed 1,450 rows in one batch and passed a transaction's 4,096 index
  ranges (a new size test; dev without the trigger passes it). Bookkeeping's batches and the steps after a save
  now take as many papers as 400 vote writes leave room for (VOTE_WRITES, measured: 800 passed, 1,000 didn't).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant